﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AlphaD.Core
{
    public class BoundaryCondition
    {

        public static BoundaryCondition CreateFirst(double x, double value)
        {
            return new BoundaryCondition()
            {
                Type = BoundaryConditionType.First,
                X = x,
                Value = value
            };
        }

        public static BoundaryCondition CreateSecond(double x, double k, double value)
        {
            return new BoundaryCondition()
            {
                Type = BoundaryConditionType.Second,
                X = x,
                K = k,
                Value = value
            };
        }

        private double _k;

        public BoundaryConditionType Type { get; private set; }
        public double X { get; private set; }
        public double K 
        { 
            get
            {
                if (this.Type == BoundaryConditionType.First)
                {
                    throw new InvalidOperationException("k is not defined if type is Second");
                }
                return this._k;
            }
            private set
            {
                if (value <= 0)
                {
                    throw new ArgumentException("k must be > 0");
                }
                this._k = value;
            }
        }
        public double Value { get; private set; }

    }
}
